﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Arith
{
    class ArrayWithForeachLoop
    {
        public static void Main()
        {
            int[] arr = new int[10]; // int array with 10 elements.

            for (int i = 0; i < 10; i++)
            {
                Console.Write("Enter a No. :");
                arr[i] = Convert.ToInt32(Console.ReadLine());
            }
            Console.WriteLine("Values with Sum:-");
            int s = 0;
            foreach (int n in arr)
            {
                Console.WriteLine(n);
                s = s + n;
            }
            Console.WriteLine("Sum = " + s);
            
            //for (int i = 0; i < 10; i++)
            //{
            //    Console.WriteLine(arr[i]);
            //    s = s + arr[i];
            //}
            //Console.WriteLine("Sum = " + s);
            Console.Read();
        }
    }
}
